//
//  LYCentral+Unit.swift
//  RxSwift_Practice
//
//  Created by 李永彬 on 2020/5/13.
//  Copyright © 2020 李永彬. All rights reserved.
//

import Foundation

extension LYCentral {
    func setUnitsForDevice(unitType:UInt8, callback: @escaping LYBCBoolCallback)  {
        let bytes:[UInt8] = [0x6F,0x0C,0x71,0x01,0x00,unitType,0x8F]
        let data = Data(bytes)
        let bluetoothData = LYBluetoothData(sendData: data, timeout: 10, type: .LYBlueToothdataTypeNormal)
        _ =  self.sendRequest(dataModel: bluetoothData, callback: { (model, errorCode) in
            if errorCode == nil {
                callback(true, nil)
        
                if let receivedData = model?.receivedData {
                    print(receivedData)
                }
//                print("回调数据：", model?.receivedData as Any)
            }
            else
            {
                callback(false, errorCode)
            }
        })
    }
}
